#include <iostream>
using namespace std;

// 1. final 修饰函数表示函数不可被重写, 修饰类表示类不可被继承   
// 2. override 对函数名的检测  表示需要被重写
class Base
{
public:
    virtual void hello()
    {
        cout << "hello - Base class...";
    }

    virtual void world() final
    {
        cout << "world - Base class...";
    }

    void print()
    {
        cout << "hello, world..." << endl;
    }
};

class Child final : public Base    //Child类没有后代,不可被继承
{
public:
    void hello() override
    {
        cout << "hello - Child class..." << endl;
    }

    void world()                  //报错：无法重写final函数
    {
        cout << "world - Child class..." << endl;
    }

    void print()
    {
        cout << "你好,世界..." << endl;
    }
};

class GrandChild : public Child     //报错：不可将finnal类类型用作基类
{
public:
    void hello()
    {
        cout << "hello - GrandChild class...";
    }
#if 1
    void world()                    //报错：
    {
        cout << "world - GrandChild class..." << endl;
    }
#endif
};


int main()
{
    return 0;
}